package StudySocket;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
//老师实验翻车哈哈哈
public class StudyHttpRespones {
    public static void main(String[] args) throws Exception{
        Socket socket=new Socket("mail.163.com",80);//http默认端口是80
       OutputStream os= socket.getOutputStream();
        InputStream is=socket.getInputStream();
        PrintWriter pw=new PrintWriter(os);
        pw.println("GET / HTTP/1.1");
        pw.println("Host: http://mail.163.com:80");
        pw.println("");//格式要求空字符串
        pw.flush();
        int x;
        while((x=is.read())!=-1){
            System.out.print((char)x);
        }
        is.close();
        os.close();
        socket.close();
    }
}
